import { request } from '@/utils/service';
import { AxiosResponse } from 'axios';


/** 获取一份数据 */
export function getData<T>(url: string): Promise<AxiosResponse<T>> {
    return request({
        url,
        method: "get",
    });
}

/** 获取一组数据 */
export function getDataset<T>(url: string): Promise<AxiosResponse<T[]>> {
    return request({
        url,
        method: "get",
    });
}

/** 创建一份数据 */
export function postData<T>(url: string, data: T) {
    return request({
        url,
        method: "post",
        data,
    });
}

/** 修改一份数据 */
export function putData<T>(url: string, data: T) {
    return request({
        url,
        method: "put",
        data,
    });
}

/** 指定主键，删除一份数据 */
export function deleteData<I>(prefix: string, pkey: I) {
    return request({
        url: `${prefix}/${pkey}`,
        method: "delete",
    });
}
